
from django.conf.urls import url
from django.contrib import admin
from rest_framework.routers import DefaultRouter
from rest_framework_jwt.views import obtain_jwt_token

from apps.meiduo_admin.views import brands,admin
from apps.meiduo_admin.views import groups
from apps.meiduo_admin.views import images
from apps.meiduo_admin.views import options
from apps.meiduo_admin.views import orders
from apps.meiduo_admin.views import permission
from apps.meiduo_admin.views import skus
from apps.meiduo_admin.views import specs
from apps.meiduo_admin.views import spus
from .views import statistical,users

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    #普通用户总数
    url(r"^statistical/total_count/$",statistical.UserTotalCountView.as_view()),
    #日增用户数量
    url(r"^statistical/day_increment/$", statistical.UserDayCountView.as_view()),
    # 日活用户数量
    url(r"^statistical/day_active/$", statistical.UserCountView.as_view()),
    # 日下单用户统计
    url(r"^statistical/day_orders/$", statistical.UserOrederCountView.as_view()),
    #月增用户统计
    url(r"^statistical/month_increment/$", statistical.UserMonthCountView.as_view()),
    #商品分类访问量统计
    url(r"^statistical/goods_day_views/$", statistical.GoodCountView.as_view()),


    # --------用户管理---------
    url(r"^users/$", users.UserView.as_view()),
    # SPU商品信息
    url(r"^goods/simple/$", specs.SpecsView.as_view({"get":"simple"})),

    #在规格选项中获取对应的规格信息路由
    url(r"^goods/specs/simple/$", options.OptionsView.as_view({"get":"simple"})),
    # 获取图片关联的sku信息...
    url(r"^skus/simple/$", images.SKUImageView.as_view({"get":"simple"})),


    ###### 获取三级分类路由
    url(r"skus/categories/$",skus.SKUView.as_view({"get":"simple"})),

    #获取商品相应的规格选项...
    url(r"goods/(?P<pk>\d+)/specs/$", skus.SKUView.as_view({"get": "specs"})),
    # 获取品牌信息
    url(r"goods/brands/simple/$", spus.SPUView.as_view({"get": "brands"})),
    #一级分类路由
    url(r"goods/channel/categories/$", spus.SPUView.as_view({"get": "channel"})),
    #二级分类路由
    url(r"goods/channel/categories/(?P<pk>\d+)/$", spus.SPUView.as_view({"get": "channel2"})),
    #spu详情图片信息路由
    url(r'goods/images/$', spus.SPUView.as_view({'post': 'images'})),
    # 权限类型路由
    url(r'permission/content_types/$', permission.PermissionView.as_view({'get': 'simple'})),

    #获取用户权限内容路由
    url(r'permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),

    #获取管理员用户分组信息路由
    url(r'permission/groups/simple/$', admin.AdminView.as_view({'get': 'groups'})),

]


# 自动生成路由
router = DefaultRouter()

#品牌管理路由
router.register("goods/brands",brands.BrandView,base_name="brands")

# 规格表路由
router.register("goods/specs",specs.SpecsView,base_name="specs")
#规格选项路由
router.register("specs/options",options.OptionsView,base_name="options")
#图片路由
router.register("skus/images",images.SKUImageView,base_name="images")
# SKU路由
router.register("skus",skus.SKUView,base_name="skus")

# SPU表路由
router.register("goods",spus.SPUView,base_name="goods")

# 订单管理路由
router.register("orders",orders.OrderView,base_name="orders")

#权限管理路由
router.register("permission/perms",permission.PermissionView,base_name="perms")

#用户分组管理路由
router.register("permission/groups",groups.GroupView,base_name="groups")

# 管理员路由
router.register("permission/admins",admin.AdminView,base_name="admins")



urlpatterns += router.urls


